package com.hyperf.core.validation.constraints;

import com.hyperf.core.validation.constraintvalidators.JsonValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * @author lizhaoyang
 */
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER, TYPE_USE })
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {JsonValidator.class})
public @interface Json {

    boolean required() default true;

    String message() default "必须是有效的JSON字符串";

    Class<?>[] groups() default { };

    Class<? extends Payload>[] payload() default { };
}
